package org.goyo.main.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.comet4j.core.CometContext;
import org.comet4j.core.CometEngine;
import org.goyo.main.comet4j.CometInit;

public class Comet4JInitListener implements ServletContextListener {
        public void contextInitialized(ServletContextEvent sctex) {
          new CometInit(sctex);
               /* CometContext cc = CometContext.getInstance();
                cc.registChannel(CHANNEL);//注册应用的channel
               Thread helloAppModule = new Thread(new HelloAppModule(), "Sender App Module");
                helloAppModule.setDaemon(true);
                helloAppModule.start();*/
               /* CometEngine engine = CometContext.getInstance().getEngine();
                engine.sendToAll(CHANNEL, Runtime.getRuntime().freeMemory()/1024);*/

        }

        /*class HelloAppModule implements Runnable {
                public void run() {
                        while (true) {
                                try {
                                        Thread.sleep(1000);
                                } catch (Exception ex) {
                                        ex.printStackTrace();
                                }
                                CometEngine engine = CometContext.getInstance().getEngine();
                                engine.sendToAll(CHANNEL, Runtime.getRuntime().freeMemory()/1024);
                        }
                }
        }*/

        public void contextDestroyed(ServletContextEvent arg0) {

        }
}
